You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): ODT previews no longer print an index's title twice or its entry separators - #40509
The Files preview of an OpenDocument text file prints an index's source as if it were content. Open LibreOffice's Tabs-in-TOC.odt test document in Files: "Table of Contents" appears twice. In BibliographyEntryField.odt, the bibliography is preceded by a line of Bibliography: , , : , , : , , ….
ODF stores an index in two parts: the source it is generated from (text:table-of-content-source and its siblings), then the generated body (text:index-body). The source holds a title template and the entry templates, whose fixed separator strings are character data. odfHtml emits the text of any element it does not skip, so it prints the title template before the real title and the entry templates' separators as a run of punctuation. ODF 1.3 part 3 §8.2.1 says the source "contains the information necessary to generate the index content"; the body holds the content.
Change
odfHtml now skips the seven index source elements (table of contents, illustration, table, object, user, alphabetical, bibliography), next to the elements it already skips. That is the complete set in ODF 1.3. The generated body, which holds the title and the entries, is rendered as before.
Limit: an index with a source and no generated body now shows nothing, where main showed the bare template title. pandoc's ODT template writes its table of contents that way, to be generated when the file is opened in a word processor. textutil also prints nothing for it. None of the 77 indexes in the documents I compared lacks a body.
Scope
Small fix for a directly reproducible preview bug, so there is no separate issue. Web and desktop share this reader and mobile has none. Presentations and drawings go through the same function and are unchanged; spreadsheets do not use it. I searched open and closed PRs and issues for ODT indexes, tables of contents, bibliographies and odfHtml and found nothing covering this. Open PR #38542 touches the server's extractor only.
Verification
I found this by running the web reader and textutil -convert txt over LibreOffice's ODT test documents and looking at files where the preview had text that textutil did not.
Files panel, web dev client (Chromium, macOS),main and this branch:
Before
After
Tabs-in-TOC.odt
BibliographyEntryField.odt
The preview's HTML for the first file changed from …<p>c</p>Table of Contents<p>Table of Contents</p>… to …<p>c</p><p>Table of Contents</p>….
Real documents: ran main's reader and this one over 1,866 .odt/.ott files (1,176 from LibreOffice's tests, 690 from the ODF Toolkit and pandoc tests) and 930 presentation, drawing and spreadsheet files.
49 ODT outputs change; no other format changes. Every change is a deletion of bare text with identical markup, equal to running main's reader on the same XML with the index sources cut out.
47 of the 49 lose a duplicate of a title that is still shown in the body; 6 lose separator runs; no file loses a title that existed only in the source.
Checked against textutil on all 49: 47 match the fixed output. In one of the other two the index sits in a text box and textutil itself prints the title twice; in the other the indexes sit in a footnote, which textutil omits.
Test: the existing ODT case now includes all seven index kinds and asserts the page's HTML. It fails on main (<p>Field notes</p>Index: <p>Index</p>… where <p>Field notes</p><p>Index</p>… is expected), fails if any one of the seven names is removed, and passes here. vp test run src/components/files/FilePreviewPanel.test.ts passes 43/43.
vp run check:changed passes: format, lint, knip, typecheck, tests and the React compiler check.
Not checked: ODT files exported by Word, Google Docs or Pages (the Word-written files in the corpus contain no index, and textutil writes none), and the packaged desktop app. The server's text extractor shows the same duplicate title for attachments; this PR does not touch it.
Written by Claude Fable 5.2 in Claude Code, run from T3 Code.
…entry separators
An OpenDocument index (table of contents, bibliography, table of figures
and the other four kinds) is stored as two parts: the source it is
generated from, then the generated body. The ODT preview printed the text
of both, so a LibreOffice table of contents showed "Table of Contents"
twice, and a bibliography was preceded by a run of the separators from
its entry templates (": , , : , , ...").
The reader now skips the seven index source elements and shows only the
index body, which already holds the title and the entries.
Claude Fable 5.2 in Claude Code, running in T3 Code.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reviewing files that changed from the base of the PR and between d2d90d5 and d0cfc80.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The ODT preview conversion now omits seven ODF index and bibliography source elements. The ODT test adds fixtures for those types and checks the expected output. ODP assertions remain unchanged.
Changes: ODT index source filtering
Layer / File(s)
Summary
Filter index source elements and verify ODT output apps/web/src/components/files/extendedDocumentPreview.ts, apps/web/src/components/files/FilePreviewPanel.test.ts
odfHtml omits seven ODF index and bibliography source elements. The ODT test adds fixtures for those types and asserts the expected output. The ODP assertions remain unchanged.
ODT previews will no longer show an index's title twice or its template separators. The one stated limitation is that an index with no generated body now renders nothing. The change is small and covered by an updated test, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: ODT previews no longer print an index's title twice or its entry separators. The raw summary and objectives confirm that odfHtml now skips seven ODF index source eleme…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the bug with reproduction files and expected behavior. The Change section e…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: ODT previews no longer print an index's title twice or its entry separators. The raw summary and objectives confirm that odfHtml now skips seven ODF index source elements, which removes the duplicate title and separator runs. The title is specific and matches the changeset. Its length (85 characters) is long but acceptable.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the bug with reproduction files and expected behavior. The Change section explains the seven skipped elements and the limit. The Scope section explains why no issue is linked and says the change is a small fix. Verification gives focused tests, a corpus comparison, before/after screenshots, and the checks run. It also states what was not checked. The template asks for a conventional commit title; the title meets this. The description is mostly complete. One gap: the Scope section gives no linked issue. It gives a reason for skipping one, which the template allows for small obvious fixes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Real web app, Chromium, light theme, 1440×1000, fresh isolated state on each commit. Seed the two original LibreOffice ODT samples, open a replay thread, then right panel → Files → Tabs-in-TOC.odt → BibliographyEntryField.odt.
The base visibly duplicates the index titles and prints bibliography template separators. The head renders each title and its entries once without that punctuation. scenarios:prove exited 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Files preview of an OpenDocument text file prints an index's source as if it were content. Open LibreOffice's Tabs-in-TOC.odt test document in Files: "Table of Contents" appears twice. In BibliographyEntryField.odt, the bibliography is preceded by a line of
Bibliography: , , : , , : , , ….ODF stores an index in two parts: the source it is generated from (
text:table-of-content-sourceand its siblings), then the generated body (text:index-body). The source holds a title template and the entry templates, whose fixed separator strings are character data.odfHtmlemits the text of any element it does not skip, so it prints the title template before the real title and the entry templates' separators as a run of punctuation. ODF 1.3 part 3 §8.2.1 says the source "contains the information necessary to generate the index content"; the body holds the content.Change
odfHtmlnow skips the seven index source elements (table of contents, illustration, table, object, user, alphabetical, bibliography), next to the elements it already skips. That is the complete set in ODF 1.3. The generated body, which holds the title and the entries, is rendered as before.Limit: an index with a source and no generated body now shows nothing, where
mainshowed the bare template title. pandoc's ODT template writes its table of contents that way, to be generated when the file is opened in a word processor.textutilalso prints nothing for it. None of the 77 indexes in the documents I compared lacks a body.Scope
Small fix for a directly reproducible preview bug, so there is no separate issue. Web and desktop share this reader and mobile has none. Presentations and drawings go through the same function and are unchanged; spreadsheets do not use it. I searched open and closed PRs and issues for ODT indexes, tables of contents, bibliographies and
odfHtmland found nothing covering this. Open PR #38542 touches the server's extractor only.Verification
I found this by running the web reader and
textutil -convert txtover LibreOffice's ODT test documents and looking at files where the preview had text thattextutildid not.mainand this branch:The preview's HTML for the first file changed from
…<p>c</p>Table of Contents<p>Table of Contents</p>…to…<p>c</p><p>Table of Contents</p>….main's reader and this one over 1,866.odt/.ottfiles (1,176 from LibreOffice's tests, 690 from the ODF Toolkit and pandoc tests) and 930 presentation, drawing and spreadsheet files.main's reader on the same XML with the index sources cut out.textutilon all 49: 47 match the fixed output. In one of the other two the index sits in a text box andtextutilitself prints the title twice; in the other the indexes sit in a footnote, whichtextutilomits.main(<p>Field notes</p>Index: <p>Index</p>…where<p>Field notes</p><p>Index</p>…is expected), fails if any one of the seven names is removed, and passes here.vp test run src/components/files/FilePreviewPanel.test.tspasses 43/43.vp run check:changedpasses: format, lint, knip, typecheck, tests and the React compiler check.textutilwrites none), and the packaged desktop app. The server's text extractor shows the same duplicate title for attachments; this PR does not touch it.Written by Claude Fable 5.2 in Claude Code, run from T3 Code.
🤖 Generated with Claude Code